package com.dinetech.dao;

import java.util.ArrayList;

import com.dinetech.ejecutor.R;
import com.dinetech.entidades.SpinnerVarios;

import android.app.Activity;
import android.content.Context;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

public class SpinnerVariosAdapter extends BaseAdapter {

	protected Activity activity;
	protected Fragment fragment;
	protected ArrayList<SpinnerVarios> items;
	
	public SpinnerVariosAdapter(Activity activity, ArrayList<SpinnerVarios> items){
		this.activity = activity;
		this.items = items;	
	}
	
	public SpinnerVariosAdapter(Fragment fragment, ArrayList<SpinnerVarios> items){
		this.fragment = fragment;
		this.items = items;	
	}


	@Override
	public int getCount() {		
		return this.items.size();
	}
	
	@Override
	public Object getItem(int position) {
		
		return items.get(position);
	}

	@Override
	public long getItemId(int position) {
		
		return items.get(position).getId();
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		View vi = convertView;
		
		if(convertView == null) {
        	LayoutInflater inflater = (LayoutInflater)parent.getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE); 
        	vi = inflater.inflate(R.layout.spinner_varios_item, null);
        }
            
        SpinnerVarios item = items.get(position);                
        TextView descripcion= (TextView) vi.findViewById(R.id.txtDescipcionSpinner);
        descripcion.setText(item.getDescripcion());

        return vi;

	}

}
